import React from 'react';

export default class CommentList extends React.Component {
  render() {
    const { list, handleDel } = this.props;
    return !list.length ? (
      <div>暂无数据</div>
    ) : (
      <ul>
        {list.map((item) => {
          return (
            <li key={item.id}>
              <h3>评论人: {item.username}</h3>
              <p>评论内容：{item.content}</p>
              <button onClick={() => handleDel(item.id)}>删除</button>
            </li>
          );
        })}
      </ul>
    );
  }
}
